Skip to content

Prototype : Implement slug generation feature with UI and tests - #897

Merged
dkotter merged 54 commits into
WordPress:developfrom
milindmore22:feat/suggest-permalink
Aug 11, 2026
Merged

Prototype : Implement slug generation feature with UI and tests#897
dkotter merged 54 commits into
WordPress:developfrom
milindmore22:feat/suggest-permalink

Conversation

@milindmore22

@milindmore22 milindmore22 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What?

Closes #876

This PR introduces the Slug Generation experimental feature (ai/slug-generation ability & experiment). It provides AI-assisted permalink suggestions directly inside the WordPress Block Editor based on post title, content, and additional context.

Open Questions

Pre-publish panel, sidebar-next-to-slug, or both? See above, this affects where the ability gets wired into the editor UI. [I think starting with just the sidebar-next-to-slug would suffice]

Both entry points (sidebar popover + pre-publish panel) are currently supported in prototype.

Should slug suggestions consider existing permalinks on the site to avoid near-duplicate slugs, or is that out of scope for v1?

WordPress core natively enforces slug uniqueness on post save, not sure if we should cover this in Slug generation

Does this warrant a WP-CLI command for bulk slug review/regeneration on existing content, similar to the alt-text bulk command?

Not covered in prototype, but we can cover if required.

Why?

Creating concise, keyword-rich, and SEO-friendly permalink slugs often requires extra effort from content creators. This feature streamlines the publishing workflow by automatically suggesting URL-safe slugs within the permalink inspector popover and the pre-publish panel.

How?

  • Abilities API Integration:

    • Implemented WordPress\AI\Abilities\Slug_Generation\Slug_Generation extending Abstract_Ability.
    • Added system instructions (system-instruction.php) enforcing URL-safe, lowercase, hyphenated slug generation.
    • Sanitizes and validates outputs using sanitize_title().
  • Experiment Framework:

    • Added WordPress\AI\Experiments\Slug_Generation\Slug_Generation under Experiment_Category::EDITOR.
    • Localized configuration settings (minimum content length requirement, number of suggestions).
  • Block Editor UI Components:

    • Permalink Inspector Button: Injects a "Generate Slug" button into the Block Editor permalink popover (.editor-post-url).
    • Interactive Modal (SlugGenerationModal): Renders a modal interface allowing users to preview, manually edit, select, or regenerate slug options.
    • Pre-Publish Panel (SlugPrePublishPanel): Adds a PluginPrePublishPanel sidebar card to review or change the post slug prior to publishing.
  • Automated Tests:

    • Added PHP integration test coverage (Slug_GenerationTest.php) for ability execution, argument validation, and permissions.
    • Updated E2E helper routines (helpers.ts) for reliable REST API save synchronization during bulk toggle tests.

Use of AI Tools

AI assistance: Yes
Tool(s): Antigravity AI
Model(s): Gemini 3.6 Flash
Used for: Initial implementation of ability and experiment classes, React UI components, unit/integration tests, and code documentation. Final changes reviewed and verified by human developer.

Testing Instructions

  1. Ensure global AI features and an AI Connector with text generation capabilities are active.
  2. Navigate to Settings > AI and enable the Slug Generation experiment under Editor Experiments.
  3. Create a new post in the Block Editor and add a post title and content (at least 250 characters).
  4. Click on the Permalink / URL field in the document sidebar to open the permalink popover.
  5. Click Generate Slug. Verify the modal pops up with 3 generated slug suggestions.
  6. Select a suggested slug (or edit it in the input field) and click Insert. Verify the post permalink updates.
  7. Click Publish to open the pre-publish panel. Verify the Suggested Slugs pre-publish panel appears and allows applying suggestions.

Screenshots or screencast

Screen.Recording.2026-07-24.at.4.59.49.PM.2.mov

Changelog Entry

Feature : Slug generation feature to suggest SEO-friendly permalinks in the Block Editor.

Open WordPress Playground Preview

@milindmore22
milindmore22 requested a review from a team July 24, 2026 11:46
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: milindmore22 <milindmore22@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.72340% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.92%. Comparing base (1608cbf) to head (0bf9823).

Files with missing lines Patch % Lines
...udes/Abilities/Slug_Generation/Slug_Generation.php 98.94% 2 Missing ⚠️
...s/Abilities/Slug_Generation/system-instruction.php 85.71% 1 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #897      +/-   ##
=============================================
+ Coverage      75.46%   75.92%   +0.46%     
- Complexity      2924     2982      +58     
=============================================
  Files            121      124       +3     
  Lines          11597    11832     +235     
=============================================
+ Hits            8752     8984     +232     
- Misses          2845     2848       +3     
Flag Coverage Δ
unit 75.92% <98.72%> (+0.46%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkotter dkotter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good, tested well. I've left a handful of comments but let me know if there's questions on any of those. In addition, we'll want to ensure we add proper documentation that matches all of our other experiment docs.

Comment thread includes/Abilities/Slug_Generation/Slug_Generation.php Outdated
Comment thread includes/Abilities/Slug_Generation/Slug_Generation.php Outdated
Comment thread includes/Abilities/Slug_Generation/Slug_Generation.php Outdated
Comment thread includes/Abilities/Slug_Generation/system-instruction.php Outdated
Comment thread includes/Experiments/Slug_Generation/Slug_Generation.php Outdated
Comment thread src/experiments/slug-generation/components/SlugGenerationModal.tsx Outdated
Comment thread src/experiments/slug-generation/components/SlugGenerationModal.tsx
Comment thread src/experiments/slug-generation/components/SlugGenerationButton.tsx Outdated
Comment thread src/experiments/slug-generation/index.tsx Outdated
@jeffpaul jeffpaul modified the milestones: Future Release, 1.3.0 Aug 5, 2026
@jeffpaul

jeffpaul commented Aug 5, 2026

Copy link
Copy Markdown
Member

@milindmore22 are you able to make the updates from Darin's review above?

@milindmore22

Copy link
Copy Markdown
Contributor Author

@jeffpaul Yes, I’m addressing the PR reviews. The ones with 👍🏼 have been addressed, and I’ll work on the rest of them today.

@milindmore22
milindmore22 requested a review from dkotter August 6, 2026 11:59

@jeffpaul jeffpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Slug suggestions modal, when the Regenerate button is loading let's ensure the text there matches other loading states (e.g. "Generating...").

@jeffpaul jeffpaul mentioned this pull request Aug 10, 2026
47 tasks
@milindmore22
milindmore22 requested a review from jeffpaul August 11, 2026 09:41
@dkotter
dkotter merged commit 26356e9 into WordPress:develop Aug 11, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New Experiment: Suggest permalink slugs

3 participants